package giveGem;

public class Solution {
    public int giveGem(int[] gem, int[][] operations) {
        //
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int[] ope: operations) {
            int t = gem[ope[0]]/2;
            gem[ope[0]]-=t;
            gem[ope[1]]+=t;
        }
        for (int g: gem) {
            max = Math.max(g,max);
            min = Math.min(g,min);
        }
        return max - min;
    }
}
